package com.hdu.point_offer;

public class lcr120 {
    class Solution {
        public int findRepeatDocument(int[] documents) {
            for (int i = 0; i < documents.length; i++)
            {
                while (documents[i] - 1 != i)
                {
                    int index = documents[i] - 1;
                    if (documents[index] == documents[i]) return documents[i];

                    int tmp = documents[i];
                    documents[i] = documents[index];
                    documents[index] = tmp;
                }
            }

            return -1;
        }
    }
}
